home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 1
/
SPACE - Library 1 - Volume 1.iso
/
apps
/
514
/
i_floyd
/
i_floyd.txt
< prev
Wrap
Text File
|
1991-05-11
|
8KB
|
180 lines
--------------------------------------
Program: I_FLOYD.prg
Date : 11 Apr 91
Author : W.D.Parks
Purpose: View color IMG files in Mono
--------------------------------------
I_Floyd
from Dr. Bobware
(C) Copyright 1991 W.D. Parks
All rights reserved
I_Floyd uses the Floyd-Steinberg algorithm to convert a
color IMG file into a half-toned monochrome image.
This program is a Preview (or demo or beta-release) of a
new module for MVG that will be on MODULES DISK #2, RSN.
Similar to MVG's pal Floyd, I_Floyd reads a color IMG and
converts the colors into grey-level values for display on
a monochrome screen using error diffusion. The results are
quite striking!
Complete control is yours via the dialog. The familiar YIQ
and AVG selections are there along with some others.
For those who are not familiar with MVG's Floyding of Low-
Rez color pics, we'll cover these points briefly here.
I_Floyd processes can be divided into two major steps:
1) Converting a color into a grey value from 0-255
2) Converting pixels into a final bitimage using the grey values.
Converting to grey is done by mapping each color in the palette
to a different value according to it's associated R,G and B
intensities.
The simplest way to do this is to add the three intensities
together and divide by three, giving an AVERAGE (ie AVG) for
each palette entry.
An often better method is to use the same equation that is used
by the television industry to convert color pictures into a
black-and-white picture. This is easily done and the results
are much better than the averaging method.
((RED*30) + (GREEN*59) + (BLUE*11) ) / 100
or, more clearly, (RED*0.30) + (GREEN*0.59) + (BLUE*0.11)
For a 16 color image, there are 16 palette entries. One for
each color (but you knew that;). Each color has three values;
one for RED, one for GREEN and one for BLUE.
We convert each palette color by whichever method desired, AVG
or YIQ, and build a map or table of GREY levels.
The standard ST palette uses only three bits for each intensity
of R,G and B. This is a maximum of 7 for each; not a very wide
range.
In I_FLOYD, we first expand this into a larger bandwidth, 0-255.
We multiply each color by 36, giving us a maximum of 255. This
is then placed in the grey table.
Conversion to a bitimage is a little more complex but briefly,
Each grey value is compared with a threshold (128). If the value
is below 128 we consider it to be BLACK and distribute the remainder
to the surrounding pixels. If it is above 128, we consider it to
be WHITE and also distribute the remainder to the surrounding
pixels.
Our "distribution" is divided into four directions. Some goes to
the pixel to the right (EAST), some goes to the pixel to the right
and downward (SouthEAST), some goes directly downward (SOUTH) and
some goes down and to the left (SouthWEST).
The default allocation is:
EAST : 7/16
S.EAST: 5/16
SOUTH : 3/16
S.WEST: 1/16
Additionally, I_FLOYD offers a sizing factor of x1 or x2.
[x1] will display the image in it's original dimensions.
[x2] will enlarge it x2 in both directions, Vert & Horiz.
MVG itself reads only MONOCHROME IMG files. This is well and
good since most IMG files are monocrome (single plane) anyway.
No provision was made for color IMGs due the lack of any standard
for color information. For the longest time, the only program
that could correctly read a particular color IMG was the program
that created it in the first place.
As of this writing, several different methods are required for
reading color IMG's. Some of the formats are very-very close to
the original DRI specifications for IMG files (of either type),
while other color IMG formats veer sharply from the documented
specs.
I_FLOYD makes provisions for a number of these. The default
settings are for normal "SEPARATE PLANE BLOCKS" and for ATARI/ST
palette organization (single word entries).
Options are included for interleaved rasters (said to be the format
of "Hyperpaint") and even for interleaved words (as seen in Degas
images).
Three (and a half) options exist for palette styles.
Single Word (default) $0777 for RGB
3-byte triplets $07,$07,$07 for R,G,B
3-word triplets $0007,$0007,$0007 for R,G,B
3-word triplets, range to 1000 " " " " " " "
Additionally, some color IMG formats use a signature word or
longword to identify themselves. At this time, I_FLOYD will
recognize "XIMG", "STTT" and "CIMG". $0080 is also recognized
and certain options are pre-set.
Since there is no prescribed method of determining all of these
options automatically, I_FLOYD simply provides the [BUTTONS] for
manual control. Some signatures will pre-set some options but it
cannot guarantee 100% success.
For normal IMG files, [Hue Expanse] should default to 36. This
expands the normal ST color range from 0-7 to 0-255.
For STTT files, all is normal.
For XIMG files, [Hue Expanse] defaults to 10.
For $0080 signatures, the PLANE type should be set to [Leaved Rasters].
I_FLOYD can read single-plane IMGs (mono), 4-plane IMGs (16 color)
and 8-plane IMG's (256 color).
Does all this sound confusing? Sure does to me! <grin>
Play with I_FLOYD. I'd include some sample color IMG files but the
only ones I've seen are er... uh... well... a bit on the ribald
side and I wouldn't want to offend anyone.
CHQ BBS has some color IMG's, so does GEnie.
In any event, take a look-see. Let me know what you think would make
I_FLOYD better. Let me know if you want a specific color IMG format
supported...
From all angles, the "STTT" format is the simplest to understand and
is the most accurate since it leaves nothing to be "assumed".
It also follows the original DRI specifications as close as possible.
MVG will support this STTT format in any future releases or modules.
As always with Dr. Bobware's freebee programs, this program may be
freely distributed as long as this documentation is included and
as long as neither are modified in any way. (Yepper. That means
my spelling errors are now etched in stone.)
Bye:Dr. Bob
11 Apr 91
W. David Parks
CHQ BBS : Dr. Bob (216) 793-9765 12/24 8/n/1 24hrs
GEnie adrs: W.Parks3